package com.mz.ozy.widget.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.webkit.WebView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.mz.ozy.R;
import com.mz.ozy.utils.Utils;

public class MsgDialog extends Dialog {
    private Context mContext;
    String title;
    String content;

    public MsgDialog(Context context, String title, String content) {
        super(context, R.style.dialogtheme);
        this.mContext = context;
        this.title = title;
        this.content = content;

    }

    public MsgDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
    }

    protected MsgDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_msg, null);
        setContentView(view);
        final WebView webView = view.findViewById(R.id.webview);
        final TextView tvTitle = view.findViewById(R.id.tv_title);
        // tvContent.setText(Html.fromHtml(content).toString());
        webView.loadDataWithBaseURL(null, Utils.getNewContent(content), "text/html", "utf-8", null);

        tvTitle.setText(title);
        view.findViewById(R.id.bt_confirm).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        view.findViewById(R.id.iv_msg_close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });

    }

}
